package sv;

import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class LopHoc {
	private List<SinhVien> ds;
	
	//constructor
	public LopHoc() {
		ds = new ArrayList<SinhVien>();
	}
	
	//nhap sinh vien tu file co san
	public void nhapDSSV(String file) {
		
		//mo file
		File f = new File(file);
		Scanner scanner;
		
		try {
			//nhap noi dung tu file
			scanner = new Scanner(f);
			
			//trong khi con noi dung de doc
			while(scanner.hasNext()) {
			
				int n = scanner.nextInt();
				
				//neu kiem tra ton tai la false (sinh vien chua  ton tai)
				if(!ktTonTai(n)) {
					
					//tao doi tuong sv
					SinhVien sv = new SinhVien();
					
					//tao ma so cho sinh vien
					sv.getMSSV();
					
					//dua sinh vien vao danh sach
					ds.add(sv);
				}
			}
		}
		catch (FileNotFoundException e) {
			e.printStackTrace();
		}
	}
	
	//them 5 sinh vien
	public void themSinhVien() {
		Scanner scanner = new Scanner(System.in);
		
		for(int i = 0; i < 5; i++) {
			int n = scanner.nextInt();
			if(!ktTonTai(n)) {
				
				SinhVien sv = new SinhVien();
				
				sv.getMSSV();
				
				ds.add(sv);
				
			}
		}
		
		
	}
	
	//ham kiem tra sinh vien co ton tai chua
	public boolean ktTonTai(int n) {
		for(SinhVien sv: ds) {
			if(sv.getMSSV() == n) {
				return true;
			}
		}
		return false;
	}

}
